#! /usr/bin/python3
# coding=utf-8
# ******************************************************************************
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
# licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# Author: senlin
# Create: 2022-11-13
# ******************************************************************************/

from src.libs.logger import logger


class ApiException(Exception):
    """
    api异常类
    """

    def __init__(self, code, msg):
        self.code = code
        self.msg = msg

    def __str__(self):
        return "request failed, code={0}, msg={1}".format(self.code, self.msg)

class OectProcessEventException(Exception):
    """
    Oect处理事件时遇到的异常场景类
    """
    error_code = {
        101: "No valid branch or project for input.",
        102: "gitee_api_config.yaml not exists",
        103: "No build env info in es.",
        104: "No build status info in cache."
        }
        
    def __init__(self, code, msg=''):
        self.code = code
        self.msg = msg

    def __str__(self):
        return "ErrCode: %s, ErrorInfo: %s, details: %s" % (self.code, self.error_code[self.code], self.msg)